<template>
  <div :id="id" style="width: 100%;height: 6.25rem;margin-top: 0.625rem"></div>
</template>

<script>
    export default {
      props: ['id', 'options'],
      watch: {
        title: {
          handler(newVal, oldVal) {
            if (newVal) {
              this.getEchartsData()
            }
          },
          deep: true
        }
      },
      methods:{
        // 折线图数据渲染
        getEchartsData() {
          let myChart = this.$echarts.init(document.getElementById(this.id))
          var option = this.options
          setInterval(function () {
            option.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
            myChart.setOption(option, true);
          },2000);
        }
      },
      mounted() {
        this.getEchartsData()
      }
    }
</script>
